package com.dyna.api.domain.entity;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.dyna.constants.DateFatter;
import com.dyna.domain.dto.LoginUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * OAuth2 访问令牌 DO
 */
@TableName(value = "system_oauth2_access_token", autoResultMap = true)
@KeySequence("system_oauth2_access_token_seq")
@Data
@Accessors(chain = true)
public class SysOAuth2AccessToken {

    @ApiModelProperty(value = "编号，数据库递增")
    @TableId
    private Long id;

    @ApiModelProperty(value = "访问令牌")
    private String accessToken;

    @ApiModelProperty(value = "刷新令牌")
    private String refreshToken;

    @ApiModelProperty(value = "用户编号")
    private Long userId;

    @ApiModelProperty(value = "用户类型, 枚举: UserTypeEnum")
    private Integer userType;

    @ApiModelProperty(value = "用户信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private LoginUser userInfo;

    @ApiModelProperty(value = "客户端编号, 关联: OAuth2ClientDO.getId()")
    private String clientId;

    @ApiModelProperty(value = "授权范围")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> scopes;

    @ApiModelProperty(value = "过期时间")
    @JsonFormat(pattern = DateFatter.YYYY_MM_DD_HH_MM_SS)
    private LocalDateTime expiresTime;

    /**
     * {@link com.dyna.enums.DeleteValueEnum}
     */
    @ApiModelProperty(value = "删除标识", notes = "0-正常，2-删除")
    private Integer delFlag;

}